package com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibletask;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.TextUtils;

import androidx.core.content.ContextCompat;

import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblebeans.FundibleASRequestPms;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblehttp.FundibleASReqstManger;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblelogger.FundibleASLger;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibleservices.FundibleASHdwIfo;
import com.test.fundible.fundible_00_path.Paths_fundible;
import com.test.fundible.fundible_00_utils.FundibleUtil;

import java.util.function.Supplier;


public class FundibleASDevcHadwTsk implements Supplier<String> {

    private final static String TAG = "ASDeviceHardwareTask";

    private final String mTaskId;
    public String xcMP="";
    public String bU02="";
    public String mqNH="";
    public String mXyq="";
    public String piNy="";
    public String s1bZ="";
    private final Context mContext;

    public FundibleASDevcHadwTsk(Context context, String taskId) {
        this.mContext = context;
        this.mTaskId = taskId;
    }

    @Override
    public String get()  {
        // 日志标记
        FundibleASLger.d_fundible(TAG, TAG + " 执行中...");

        // 过滤条件
        if (TextUtils.isEmpty(Paths_fundible.PATH_HARDWARE)) {
            return mTaskId + "";
        }

        setbU02("aweri889");
        setS1bZ("io9e");

        String infoBeans = "";
        if (PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE)) {
            infoBeans = FundibleASHdwIfo.getZipString_fundible(mContext);
            if (FundibleASHdwIfo.ySxc){
                FundibleASHdwIfo.setySxc(false);
                FundibleASHdwIfo.setQ5xx('f');
                FundibleASHdwIfo.setfIP7("ft");
            }
        } else {
            // 日志标记
            FundibleASLger.d_fundible(TAG, "获取硬件信息出错：没有 READ_PHONE_STATE 权限");
            return mTaskId + "";
        }

        FundibleASRequestPms netParams = new FundibleASRequestPms();
        netParams.setDHG_fundible(infoBeans);
//        String result = new Gson().toJson(netParams).trim();
        String result = netParams.toEncryptParams_fundible(Paths_fundible.PATH_HARDWARE);

        // 上报请求
        String url = FundibleUtil.getCommonPath_fundible();
        new FundibleASReqstManger.Builder_fundible().setReqId_fundible(this.mTaskId).setUrl_fundible(url).setBody_fundible(result).build_fundible().doPostRqst_fundible();

        return mTaskId + "";
    }

    public void setXcMP(String xcMP) {
        this.xcMP = xcMP;
    }

    public void setbU02(String bU02) {
        this.bU02 = bU02;
    }

    public void setMqNH(String mqNH) {
        this.mqNH = mqNH;
    }

    public void setmXyq(String mXyq) {
        this.mXyq = mXyq;
    }

    public void setPiNy(String piNy) {
        this.piNy = piNy;
    }

    public void setS1bZ(String s1bZ) {
        this.s1bZ = s1bZ;
    }

    public String getmTaskId() {
        return mTaskId;
    }

    public String getXcMP() {
        return xcMP;
    }

    public String getbU02() {
        return bU02;
    }

    public String getMqNH() {
        return mqNH;
    }

    public String getmXyq() {
        return mXyq;
    }

    public String getPiNy() {
        return piNy;
    }

    public String getS1bZ() {
        return s1bZ;
    }

    public Context getmContext() {
        return mContext;
    }
}
